/*
 * This program demonstrates a variation of
 * the for loop in creating a table of even numbers.
 *
 * Written by John Kim
 * on Sat Jan 11 12:40:00 PST 2014
 *
 * v0.1 - first release
 */
class johnEvenOdd {
    public static void main(String args[])
        throws java.io.IOException {
        int odd = 1;
        int even = 2;
        int counter = 0;
        char choice;

        // TODO Option to choose to see sum of outputted numbers.

        System.out.println("---------------------------------------");
        System.out.println("Table of Even or Odd Numbers from 0-100");
        System.out.println("---------------------------------------");
        System.out.println("Which table would you like to see?\n" +
                "  1. Even\n" + "  2. Odd");
        System.out.print("Please select one: ");
        choice = (char) System.in.read(); // Choose a character.
    
        switch(choice) {
            case '1':
                for(int i = 1; i <= 50; i++) { // i instantialized here.
                    System.out.print(even + "\t");
                    even += 2;

                    counter++;
                    if(counter == 5) {
                        System.out.println();
                        counter = 0;
                    }
                }
                break;
            case '2':
                for(int i = 1; i <= 50; i++) { 
                    System.out.print(odd + "\t");
                    odd += 2; // increment by two.

                    counter++;
                    if(counter == 5) {
                        System.out.println();
                        counter = 0;
                    }
                }
                break;
            default:
                System.out.println("Selection not allowed.");
                break;
        }
    }
}
